package com.lvcoding.codegen.controller;

import com.lvcoding.codegen.domain.Res;
import com.lvcoding.codegen.domain.TableClass;
import com.lvcoding.codegen.service.GenerateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Description 描述
 * @Date 2020-12-30 5:58 下午
 * @Author wuyanshen
 */
@RestController
public class GenerateController {

    @Autowired
    private GenerateService generateService;

    @PostMapping("/generate")
    public Res generateCode(@RequestBody List<TableClass> tableClassList, HttpServletRequest request) {
        return generateService.generateCode(tableClassList, request.getServletContext().getRealPath("/"));
    }
}
